home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axcool / contxtid.bas < prev    next >
Encoding:
BASIC Source File  |  1998-10-27  |  11.6 KB  |  264 lines

  1. Attribute VB_Name = "ContextIDs"
  2. Option Explicit
  3. '=====================================================================
  4. '=====================================================================
  5. '
  6. 'This source code contains the following routines:
  7. '  o SetAppHelp() 'Called in the main Form_Load event to register your
  8. '                 'program with WINHELP.EXE
  9. '  o QuitHelp()    'Deregisters your program with WINHELP.EXE. Should
  10. '                  'be called in your main Form_Unload event
  11. '  o ShowHelpTopic(Topicnum) 'Brings up context sensitive help based on
  12. '                  'any of the following CONTEXT IDs
  13. '  o ShowContents  'Displays the startup topic
  14. '  o HelpWindowSize(x,y,dx,dy) ' Position help window in a screen
  15. '                              ' independent manner
  16. '  o SearchHelp()  'Brings up the windows help KEYWORD SEARCH dialog box
  17. '***********************************************************************
  18. '
  19. '=====================================================================
  20. 'List of Context IDs for <axCool>
  21. '=====================================================================
  22. Global Const Hlp_Contents = 10    'Main Help Window
  23. Global Const Hlp_Revisions = 30    'Main Help Window
  24. Global Const Hlp_License = 40    'Main Help Window
  25. Global Const Hlp_Tech_Support = 50    'Main Help Window
  26. Global Const Hlp_Properties = 60    'Second Help Window
  27. Global Const Hlp_Methods = 70    'Second Help Window
  28. Global Const Hlp_Events = 80    'Second Help Window
  29. Global Const Hlp_Installation = 90    'Main Help Window
  30. Global Const Hlp_Standard = 100    'Main Help Window
  31. Global Const Hlp_BorderStyle = 110    'Second Help Window
  32. Global Const Hlp_Count = 120    'Second Help Window
  33. Global Const Hlp_ShowFlatGrey = 130    'Second Help Window
  34. Global Const Hlp_TextLabels = 140    'Second Help Window
  35. Global Const Hlp_Click = 150    'Second Help Window
  36. Global Const Hlp_DropDownClick = 160    'Second Help Window
  37. Global Const Hlp_Item = 180    'Second Help Window
  38. Global Const Hlp_ShowAboutBox = 200    'Second Help Window
  39. Global Const Hlp_UpdateButtons = 210    'Second Help Window
  40. '=====================================================================
  41. '
  42. '
  43. '  Help engine section.
  44.  
  45. ' Commands to pass WinHelp()
  46. Global Const HELP_CONTEXT = &H1 '  Display topic in ulTopic
  47. Global Const HELP_QUIT = &H2    '  Terminate help
  48. Global Const HELP_FINDER = &HB  '  Display Contents tab
  49. Global Const HELP_INDEX = &H3   '  Display index
  50. Global Const HELP_HELPONHELP = &H4      '  Display help on using help
  51. Global Const HELP_SETINDEX = &H5        '  Set the current Index for multi index help
  52. Global Const HELP_KEY = &H101           '  Display topic for keyword in offabData
  53. Global Const HELP_MULTIKEY = &H201
  54. Global Const HELP_CONTENTS = &H3     ' Display Help for a particular topic
  55. Global Const HELP_SETCONTENTS = &H5  ' Display Help contents topic
  56. Global Const HELP_CONTEXTPOPUP = &H8 ' Display Help topic in popup window
  57. Global Const HELP_FORCEFILE = &H9    ' Ensure correct Help file is displayed
  58. Global Const HELP_COMMAND = &H102    ' Execute Help macro
  59. Global Const HELP_PARTIALKEY = &H105 ' Display topic found in keyword list
  60. Global Const HELP_SETWINPOS = &H203  ' Display and position Help window
  61.  
  62. #If Win32 Then
  63.     Type HELPWININFO
  64.       wStructSize As Long
  65.       X As Long
  66.       Y As Long
  67.       dX As Long
  68.       dY As Long
  69.       wMax As Long
  70.       rgChMember As String * 2
  71.     End Type
  72.     Declare Function WinHelp Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long
  73.     Declare Function WinHelpByInfo Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, dwData As HELPWININFO) As Long
  74.     Declare Function WinHelpByStr Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData$) As Long
  75.     Declare Function WinHelpByNum Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData&) As Long
  76.     Dim m_hWndMainWindow as Long ' hWnd to tell WINHELP the helpfile owner
  77.  
  78. #Else
  79.     Type HELPWININFO
  80.         wStructSize As Integer
  81.         X As Integer
  82.         Y As Integer
  83.         dX As Integer
  84.         dY As Integer
  85.         wMax As Integer
  86.         rgChMember As String * 2
  87.     End Type
  88.     Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData As Any) As Integer
  89.     Declare Function WinHelpByInfo Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As HELPWININFO) As Integer
  90.     Declare Function WinHelpByStr Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData$) As Integer
  91.     Declare Function WinHelpByNum Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData&) As Integer
  92.     Dim m_hWndMainWindow as Integer ' hWnd to tell WINHELP the helpfile owner
  93.  
  94. #End If
  95. Dim MainWindowInfo as HELPWININFO
  96. Sub SetAppHelp (ByVal hWndMainWindow)
  97. '=====================================================================
  98. 'To use these subroutines to access WINHELP, you need to add
  99. 'at least this one subroutine call to your code
  100. '     o  In the Form_Load event of your main Form enter:
  101. '        Call SetAppHelp(Me.hWnd) 'To setup helpfile variables
  102. '         (If you are not interested in keyword searching or context
  103. '         sensitive help, this is the only call you need to make!)
  104. '=====================================================================
  105.     m_hWndMainWindow = hWndMainWindow
  106.     If Right$(Trim$(App.Path),1) = "\" then
  107.         App.HelpFile = App.Path + "axCool.HLP"
  108.     else
  109.         App.HelpFile = App.Path + "\axCool.HLP"
  110.     end if
  111. #If Win32 Then
  112.     MainWindowInfo.wStructSize = 26
  113. #Else
  114.     MainWindowInfo.wStructSize = 14
  115. #End If 
  116.     MainWindowInfo.X=256
  117.     MainWindowInfo.Y=256
  118.     MainWindowInfo.dX=512
  119.     MainWindowInfo.dY=512
  120.     MainWindowInfo.rgChMember=Chr$(0)+Chr$(0)
  121. End Sub
  122. Sub QuitHelp ()
  123.     Dim Result as Variant
  124.     Result = WinHelp(m_hWndMainWindow, App.HelpFile, HELP_QUIT, Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0))
  125. End Sub
  126. Sub ShowHelpTopic (ByVal ContextID As Long)
  127. '=====================================================================
  128. '  FOR CONTEXT SENSITIVE HELP IN RESPONSE TO A COMMAND BUTTON ...
  129. '=====================================================================
  130. '     o   For 'Help button' controls, you can call:
  131. '         Call ShowHelpTopic(<any Hlpxxx entry above>)
  132. '=====================================================================
  133. '  TO ADD FORM LEVEL CONTEXT SENSITIVE HELP...
  134. '=====================================================================
  135. '     o  For FORM level context sensetive help, you should set each 
  136. '        Me.HelpContext=<any Hlp_xxx entry above>
  137. '
  138.     Dim Result as Variant
  139.  
  140.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(ContextID))
  141.  
  142. End Sub
  143. Sub ShowHelpTopic2 (ByVal ContextID As Long)
  144. '=====================================================================
  145. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 2 ...
  146. '=====================================================================
  147. '     o   For 'Help button' controls, you can call:
  148. '         Call ShowHelpTopic2(<any Hlpxxx entry above>)
  149. '
  150.     Dim Result as Variant
  151.  
  152.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd02", HELP_CONTEXT, Clng(ContextID))
  153.  
  154. End Sub
  155. Sub ShowHelpTopic3 (ByVal ContextID As Long)
  156. '=====================================================================
  157. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 3 ...
  158. '=====================================================================
  159. '     o   For 'Help button' controls, you can call:
  160. '         Call ShowHelpTopic3(<any Hlpxxx entry above>)
  161. '
  162.     Dim Result as Variant
  163.  
  164.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd03", HELP_CONTEXT, Clng(ContextID))
  165.  
  166. End Sub
  167. Sub ShowGlossary ()
  168.     Dim Result as Variant
  169.  
  170.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(64000))
  171.  
  172. End Sub
  173. Sub ShowPopupHelp (ByVal ContextID As Long)
  174. '=====================================================================
  175. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  176. '=====================================================================
  177.     Dim Result as Variant
  178.  
  179.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXTPOPUP, Clng(ContextID))
  180.  
  181. End Sub
  182. Sub DoHelpMacro (ByVal MacroString As String)
  183. '=====================================================================
  184. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  185. '=====================================================================
  186.     Dim Result as Variant
  187.  
  188.     Result = WinHelpByStr(m_hWndMainWindow, APP.HelpFile, HELP_COMMAND, ByVal(Macrostring))
  189.  
  190. End Sub
  191. Sub ShowHelpContents ()
  192. '=====================================================================
  193. '  DISPLAY STARTUP TOPIC IN RESPONSE TO A COMMAND BUTTON or MENU ...
  194. '=====================================================================
  195. '
  196.     Dim Result as Variant
  197.  
  198.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTENTS, Clng(0))
  199.  
  200. End Sub
  201. Sub ShowContentsTab ()
  202. '=====================================================================
  203. '  DISPLAY Contents tab (*.CNT)
  204. '=====================================================================
  205. '
  206.     Dim Result as Variant
  207.  
  208.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_FINDER, Clng(0))
  209.  
  210. End Sub
  211. Sub ShowHelpOnHelp ()
  212. '=====================================================================
  213. '  DISPLAY HELP for WINHELP.EXE  ...
  214. '=====================================================================
  215. '
  216.     Dim Result as Variant
  217.  
  218.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_HELPONHELP, Clng(0))
  219.  
  220. End Sub
  221.  
  222. Sub SearchHelp ()
  223. '=====================================================================
  224. '  TO ADD KEYWORD SEARCH CAPABILITY...
  225. '=====================================================================
  226. '     o   In your Help|Search menu selection, simply enter:
  227. '         Call SearchHelp() 'To invoke helpfile keyword search dialog
  228. '
  229.     Dim Result as Variant
  230.  
  231.     Result = WinHelp(m_hWndMainWindow, APP.HelpFile, HELP_PARTIALKEY, ByVal "" )
  232.  
  233. End Sub
  234.  
  235. Sub SearchHelpKeyWord (Argument as String)
  236. '=====================================================================
  237. '  TO ADD KEYWORD SEARCH CAPABILITY...
  238. '=====================================================================
  239. '     o   In your Help|Search menu selection, simply enter:
  240. '         Call SearchHelp() 'To invoke helpfile keyword search dialog
  241. '
  242.     Dim Result as Variant
  243.  
  244.     Result = WinHelp(m_hWndMainWindow, APP.HelpFile, HELP_PARTIALKEY, ByVal Trim$(Argument))
  245.  
  246. End Sub
  247. Sub HelpWindowSize (x As Integer, y As Integer, wx As Integer, wy As Integer)
  248. '=====================================================================
  249. '  TO SET THE SIZE AND POSITION OF THE MAIN HELP WINDOW...
  250. '=====================================================================
  251. '     o   Call HelpWindowSize(x, y, dx, dy), where:
  252. '             x = 1-1024 (position from left edge of screen)
  253. '             y = 1-1024 (position from top of screen)
  254. '             dx= 1-1024 (width)
  255. '             dy= 1-1024 (height)
  256. '
  257.     Dim Result as Variant
  258.     MainWindowInfo.x = x
  259.     MainWindowInfo.y = y
  260.     MainWindowInfo.dx = wx
  261.     MainWindowInfo.dy = wy
  262.     Result = WinHelpByInfo(m_hWndMainWindow, App.HelpFile, HELP_SETWINPOS, MainWindowInfo)
  263. End Sub
  264.